/* OUTPUT TO PRINTER LANDSCAPE. */

DEFINE VARIABLE part AS CHARACTER.

part = "101-2802101".

FOR EACH in_mstr NO-LOCK WHERE in_part BEGINS part AND IN_loc BEGINS "":
    DISP "in_mstr" IN_part in_site IN_qty_oh IN_qty_avail IN_qty_nonet IN_qty_all IN_qty_req IN_qty_ord 
        WITH STREAM-IO WIDTH 200 .
END.

FOR EACH ld_det NO-LOCK WHERE ld_part BEGINS part:
    DISP "ld_det" ld_site ld_loc  ld_qty_oh ld_qty_all
        WITH STREAM-IO WIDTH 200 .
END.

FOR EACH lad_det NO-LOCK WHERE lad_part = part :
    DISP "lad_det" lad_dataset lad_site lad_loc lad_nbr lad_lot lad_qty_all lad_qty_pick 
        WITH STREAM-IO WIDTH 200 .
END.

FOR EACH mrp_det NO-LOCK WHERE mrp_part = part BREAK BY mrp_site BY mrp_type :
    ACCUMULATE mrp_qty (TOTAL BY mrp_site BY mrp_type).
    
    DISP "mrp_det" mrp_dataset mrp_site mrp_type mrp_detail mrp_nbr
         mrp_qty 
         ACCUM TOTAL BY mrp_site mrp_qty WHEN LAST-OF(mrp_site)
         ACCUM TOTAL BY mrp_type mrp_qty WHEN LAST-OF(mrp_type)
         mrp_due_date
       WITH STREAM-IO WIDTH 200 .
END.

FOR EACH sod_det NO-LOCK WHERE sod_part = part BREAK BY sod_part :
    ACCUMULATE sod_qty_all (TOTAL) .
    ACCUMULATE sod_qty_ord (TOTAL) .
    ACCUMULATE sod_qty_ship (TOTAL) .

    DISP "sod_det" sod_nbr sod_site 
         sod_qty_ord 
         ACCUM TOTAL sod_qty_ord WHEN LAST-OF(sod_part)
         sod_qty_ship 
         ACCUM TOTAL sod_qty_ship WHEN LAST-OF(sod_part)
         sod_qty_all 
         ACCUM TOTAL sod_qty_all WHEN LAST-OF(sod_part)
         sod_qty_pick 
         sod_due_date
        WITH STREAM-IO WIDTH 200 .
END.


FOR EACH wod_det NO-LOCK WHERE wod_part = part , 
    EACH wo_mstr NO-LOCK WHERE wo_nbr = wod_nbr AND wo_lot = wod_lot AND wo_status <> "C"
    BREAK BY wod_part BY wo_nbr :

    ACCUMULATE wod_qty_all (TOTAL) .
    ACCUMULATE wod_qty_req (TOTAL) .
    ACCUMULATE wod_qty_pick (TOTAL) .
    ACCUMULATE wod_qty_iss (TOTAL) .

    DISP "wod_det" wod_nbr wod_lot wod_site wod_status wo_status wo_type
         wod_qty_req 
         ACCUM TOTAL wod_qty_req WHEN LAST-OF(wod_part)
         wod_qty_iss 
         ACCUM TOTAL wod_qty_iss WHEN LAST-OF(wod_part)
         wod_qty_all 
         ACCUM TOTAL wod_qty_all WHEN LAST-OF(wod_part)
         wod_qty_pick 
         ACCUM TOTAL wod_qty_pick WHEN LAST-OF(wod_part)
         wod_qty_ret wod_qty_posted wod_qty_chg
         
        WITH STREAM-IO WIDTH 200 .
END.

FOR EACH wo_mstr NO-LOCK WHERE wo_part = part AND wo_status <> "C" BREAK BY wo_part:
    ACCUMULATE wo_qty_comp (TOTAL) .
    ACCUMULATE wo_qty_ord (TOTAL) .
    ACCUMULATE wo_qty_rjct (TOTAL) .

    DISP "wo_mstr" wo_nbr wo_lot wo_site wo_status
         wo_qty_ord 
         ACCUM TOTAL wo_qty_ord WHEN LAST-OF(wo_part)
         wo_qty_comp 
         ACCUM TOTAL wo_qty_comp WHEN LAST-OF(wo_part)
         wo_qty_rjct 
         ACCUM TOTAL wo_qty_rjct WHEN LAST-OF(wo_part)
         wo_qty_chg
         
        WITH STREAM-IO WIDTH 200 .
END.


